﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace canyinguanlixitong
{
    public partial class frmqw2st2 : Form
    {
        public frmqw2st2()
        {
            InitializeComponent();
        }
        string str = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";
        private void button3_Click(object sender, EventArgs e)
        {
            add();
        }
        //查询
        public void add() {
            SqlConnection conn = new SqlConnection(str);
            DataSet ds = new DataSet("Student");
            try
            {
                string sql=string.Empty;
                sql = @"select zxfID,fangJai,xfID,dcID,dcJai,xfJai,xfTime,userName,[Room table bill].fcCzid,xfZong from [Summary of consumption],dbo.UserTpye,[Room table bill]
where [Summary of consumption].xfUserTpye=UserTpye.userID and [Summary of consumption].fcID=[Room table bill].fcID and zxfID like'%" + this.txtzi.Text + "%'";
                SqlDataAdapter asd = new SqlDataAdapter(sql, conn);
               if (ds.Tables["Student"] != null)
                {
                    ds.Tables["Student"].Clear();

                } 
                asd.Fill(ds, "Student");
                dataGridView1.DataSource = ds.Tables["Student"];
           
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        
        }
    

        //离店查询
        private void button5_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(str);
            DataSet ds = new DataSet("Student");
            string sql = @"select zxfID,fangJai,xfID,dcID,dcJai,xfJai,xfTime,userName,[Room table bill].fcCzid,xfZong from [Summary of consumption],dbo.UserTpye,[Room table bill]
where [Summary of consumption].xfUserTpye=UserTpye.userID and [Summary of consumption].fcID=[Room table bill].fcID and zxfID like'%" + this.txtsyuno.Text + "%'";
            SqlDataAdapter asd = new SqlDataAdapter(sql,conn);
            asd.Fill(ds,"Student");
            dataGridView2.DataSource = ds.Tables["Student"];
        }

     

    }
}
